package red.mlz.app;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import red.mlz.module.properties.AliSmsProperties;
import red.mlz.module.utils.AliSmsUtil;

/**
 * @author 吕佳乐
 * @version 1.0
 * @date 2025-03-19 11:11
 */
@Configuration
@Slf4j
public class SmsConfig {

    @Bean
    @ConditionalOnMissingBean
    public AliSmsUtil aliSmsUtil(AliSmsProperties aliSmsProperties) {
        log.info("开始创建阿里云短信工具类对象:{}",aliSmsProperties);
        return new AliSmsUtil(aliSmsProperties.getEndpoint(),
                aliSmsProperties.getAccessKeyId(),
                aliSmsProperties.getAccessKeySecret(),
                aliSmsProperties.getSignName(),
                aliSmsProperties.getTemplateCode());
    }
}
